package singleCrud

import (
	"reflect"
)

// 分析结构体
func AnalyseStruct(req interface{})(Fields []*TplStructFields,EntityName string,NumField int){
	var myFields []*TplStructFields
	typeOfReq := reflect.TypeOf(req)
	EntityName = typeOfReq.Name()
	NumField = typeOfReq.NumField()
	for i := 0; i < typeOfReq.NumField(); i++ {
		// 获取每个成员的结构体字段类型
		fieldType := typeOfReq.Field(i)
		// 输出成员名和tag
		myFields = append(myFields, &TplStructFields{
			Index: fieldType.Index[0],
			Name: fieldType.Name,
			JsonName: fieldType.Tag.Get("json"),
			Description: fieldType.Tag.Get("description"),
		})
	}
	Fields = myFields
	return
}

